package com.tentact.dao;

import com.tentact.vo.Student;

import java.sql.SQLException;
import java.util.List;

/**
 * @author 侯炳超
 * @date 2021-12-13 16:10
 */
public class StuDao {
    //根据学生姓名模糊查询
    public List<Student> selectByEname(String ename){
        String sql ="SELECT s.studentid,s.studentname,s.studentsex,s.studentbirth,s.clazzid FROM student s   WHERE s.studentname LIKE ?";
        Object[] params = {"%"+ename+"%"};
        RowMapper<Student> rm = (rs) ->{
            Student student = new Student();
            try {

                student.setStudentId(rs.getInt("studentid"));
                student.setStudentname(rs.getString("studentname"));
                student.setStudentsex(rs.getString("studentsex"));
                student.setStudentbirth(rs.getString("studentbirth"));
                student.setClazzid(rs.getInt("clazzid"));

            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return student;

        };
        return DbUtil.executeQuery(sql, params, rm);

    }
}
